from bcdbd.rpc.plugins import base
from bcdbd.main.models import Barcode, Field

class Local(base.BasePlugin):
	def getBarcode(self, barcode):
		b = Barcode.objects.filter(barcode=barcode)
		if (len(b) > 0):
			final = base.Barcode(barcode,b[0].title)
			
			for field in Field.objects.filter(barcode=b[0]):
				final.fields[field.key] = field.value
			return final
		else:
			return None